package data {
	
	/**
	 * @author Brent Kersanske
	 */ 
	public class ExperimentResults {
		
		private var _demoResult:DemographicResult;
		private var _questionResults:Vector.<Result>;
		
		public function ExperimentResults() {
			_questionResults = new Vector.<Result>();
		}

		public function get demoResult():DemographicResult {
			return _demoResult;
		}
		
		public function addDemographicResult(demoResult:DemographicResult):void {
			_demoResult = demoResult;
		}		

		public function get questionResults():Vector.<Result> {
			return _questionResults;
		}
		
		public function addQuestionResult(newResult:Result):void {
			this.questionResults.push(newResult);
		}
		
		private function getQuestionResultsAsHTMLTable():String {
			var table:String = "<table border=\"1\">\n" 	  +
							   "<tr>\n"						  +
				   			   "<th>Question ID</th>\n"       +
				   			   "<th>Correct Option</th>\n"    +
				   			   "<th>Option Selected</th>\n"   + 
				   			   "<th>Reaction Time (s)</th>\n" + 
				   			   "<th>Difficulty Rating</th>\n" +
				   			   "</tr>\n";
			for each(var r:Result in this.questionResults) {
				table = table.concat(r.getResultAsHTMLRow());
			}
			table = table.concat("</table>\n");	   
			return table;
				   
		}
		
		public function getResultsAsHTMLTable():String {
			var html:String = this.demoResult.getResultsAsHTMLTable();
			html = html.concat("<hr/>");
			html = html.concat(this.getQuestionResultsAsHTMLTable());
			return html;
		}
	}
}